/*
* typescript中函数重载的写法
*   先编写重载签名,然后编写通用的函数实现
* */

/*
    // 编写重载签名
    function add(arg1: number, arg2: number): number
    function add(arg1: string, arg2: string): string
    // 编写通用的函数实现
    function add(arg1:any,arg2:any):any {
        return arg1+arg2
    }
    add(10,20)
    add("陶","品奇")
 */

/*
// 编写重载签名
function getSum(arg1: number, arg2: number): number
function getSum(arg1: string, atg2: string): string
// 编写通用的函数实现
function getSum(arg1: any, arg2: any): any {
    return arg1 + arg2
}

console.log(getSum(10, 20))
console.log(getSum("10", "30"))
 */

function getLength(arg1:any[]):number
function getLength(arg1:string):number
function getLength(arg1:any):any {
    return arg1.length
}

console.log(getLength("TYPESCRIPT"))
console.log(getLength([10,20,30,40]))
